import { defHttp } from "/@/utils/http/axios";

export enum Api {
  list      = "/menu/manager/list",
  save      = "/menu/manager/su",
  delete    = "/menu/manager/del",
  queryById = "/menu/manager/jumpSuView",
  sameMenu  = "/menu/manager/sameMenu",
  select    = "/menu/manager/treeSelect",
}

/**
 * 文章管理 - 列表
 * @param params
 */
export const list = () => defHttp.get({url: Api.list});

/**
 * 文章管理 - 通过ID获取数据
 * @param params
 */
export const queryById = (params) => defHttp.get({url: Api.queryById, params});

/**
 * 文章管理 - 保存或者更新
 * @param params
 */
export const save = (params) => {
  return defHttp.post({url: Api.save, params}, {isTransformResponse:false});
}

/**
 * 银行流水 - 通过ID删除数据
 * @param params
 */
export const del = (params, handleSuccess) => {
  return defHttp.delete({ url: Api.delete, data: params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
}

/**
 * 菜单同步到微信
 * @param params
 */
export const sameMenu = () => defHttp.get({url: Api.sameMenu}, {isTransformResponse:false});


/**
 * 菜单数据 - 树
 * @param params
 */
export const select = () => defHttp.get({url: Api.list}).then((res) => {
  // for(let i = 0; res.length > i; i++) {
  //   res[i].selectable = false
  // }
  return res.map((item) => {
    item.selectable = false;
    return item
  })
});
